import React, { Component } from 'react'
import BScroll from 'better-scroll'
export default class App extends Component {
    state = {
        list: []
    }
    render() {
        return (
            <div className='box' style={{ width: '100%', height: '250px', backgroundColor: 'red', overflow: 'hidden' }}>
                <ul>
                    {this.state.list.map((item, index) => <li key={index}>{item}</li>)}
                </ul>
                <button onClick={() => this.addList()}>添加</button>
            </div>
        )
    }
    addList() {
        var list = [1, 2, 2, 3, 12, 31, 2, 3, 12, 13, 1, 12, 31, 5, 5, 8, 9, 9, 7, 8, 10]
        this.setState({
            list
        }, () => {
            new BScroll('.box')
        })
    }
}
